#ifndef _block_h_
#define _block_h_

struct block
{
    char*   buffer;
    struct  block* next;
    volatile long refcount;

    block(char* buf)
	{
		next = 0;
		refcount = 1;
		buffer = buf;
	}

	char* offset(unsigned int index)
	{
		return (char*)&buffer[index];
	}

	struct block* duplicate() 
	{ 
		++refcount;
        return this;
	} 

	bool release()
	{
		return --refcount == 0;		
	}
};

#endif